Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✱ Stainless preview buildsThis PR will update the kotlin openapi python typescript Edit this comment to update them. They will appear in their respective SDK's changelogs. ✅ grid-typescript studio · code · diff
✅ grid-python studio · code · diff
✅ grid-kotlin studio · code · diff
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |
Greptile SummaryThis PR refactors transaction schema inheritance to properly handle polymorphic types using OpenAPI's
The refactoring improves OpenAPI schema validation and documentation clarity by properly implementing discriminated unions, though it does add a layer of indirection ( Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| .stainless/stainless.yml | Added stainless command to remove type property from Transaction base schema to prevent allOf conflicts |
| openapi/components/schemas/transactions/TransactionOneOf.yaml | New schema using oneOf discriminator to properly distinguish between incoming and outgoing transactions |
| openapi/components/schemas/transactions/IncomingTransaction.yaml | Added required type property with INCOMING enum value for proper polymorphic type handling |
| openapi/components/schemas/transactions/OutgoingTransaction.yaml | Added required type property with OUTGOING enum; removed paymentInstructions from required (flagged in previous review) |
| openapi/paths/transactions/transactions.yaml | Updated list endpoint to return TransactionOneOf instead of Transaction for proper type discrimination |
| openapi.yaml | Compiled OpenAPI spec with all transaction schema changes and endpoint updates applied |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class Transaction {
+string id
+TransactionStatus status
+string type
+TransactionDestinationOneOf destination
+string customerId
+string platformCustomerId
+datetime settledAt
+datetime createdAt
+datetime updatedAt
+string description
}
class TransactionOneOf {
<<oneOf>>
discriminator: type
}
class IncomingTransaction {
+string type = "INCOMING"
+CurrencyAmount receivedAmount
+TransactionSourceOneOf source
+ReconciliationInstructions reconciliationInstructions
+IncomingRateDetails rateDetails
+IncomingTransactionFailureReason failureReason
}
class OutgoingTransaction {
+string type = "OUTGOING"
+CurrencyAmount sentAmount
+CurrencyAmount receivedAmount
+TransactionSourceOneOf source
+number exchangeRate
+int64 fees
+string quoteId
+PaymentInstructions[] paymentInstructions
+Refund refund
+OutgoingRateDetails rateDetails
+OutgoingTransactionFailureReason failureReason
}
Transaction <|-- IncomingTransaction : extends via allOf
Transaction <|-- OutgoingTransaction : extends via allOf
TransactionOneOf *-- IncomingTransaction : discriminates
TransactionOneOf *-- OutgoingTransaction : discriminates
note for TransactionOneOf "API endpoints now reference\nTransactionOneOf instead of\nTransaction base schema"
note for IncomingTransaction "type property added\nto required fields"
note for OutgoingTransaction "type property added;\npaymentInstructions removed\nfrom required fields"
Last reviewed commit: 8ad3ce8
2e13aea to
36ee105
Compare
36ee105 to
c774ff0
Compare
| - $ref: ./Transaction.yaml | ||
| - type: object | ||
| required: | ||
| - type |
There was a problem hiding this comment.
Check that removing paymentInstructions from required fields is intentional and won't break existing clients
Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/transactions/OutgoingTransaction.yaml
Line: 5
Comment:
Check that removing `paymentInstructions` from required fields is intentional and won't break existing clients
How can I resolve this? If you propose a fix, please make it concise.c774ff0 to
eb98c72
Compare
.stainless/stainless.yml
Outdated
| @@ -429,6 +430,20 @@ openapi: | |||
| # - "$.components.schemas.BusinessBeneficiary.allOf[1].properties" | |||
| # keys: [ "beneficiaryType" ] | |||
| # ── customerType: remove from base schemas ── | |||
| ======= | |||
| # ── type: transaction base schema ── | |||
| - command: remove | |||
| reason: >- | |||
| Remove inline type enum from Transaction base schema to avoid | |||
| conflicting types when allOf merges with IncomingTransaction and | |||
| OutgoingTransaction which define type as single-value enums | |||
| args: | |||
| target: | |||
| - "$.components.schemas.Transaction.properties" | |||
| keys: [ "type" ] | |||
|
|
|||
| # ── beneficiaryType: beneficiary schemas ── | |||
| >>>>>>> c774ff0 (feat: fixing transaction schema) | |||
There was a problem hiding this comment.
Unresolved merge conflict will break the build
| # ── type: transaction base schema ── | |
| - command: remove | |
| reason: >- | |
| Remove inline type enum from Transaction base schema to avoid | |
| conflicting types when allOf merges with IncomingTransaction and | |
| OutgoingTransaction which define type as single-value enums | |
| args: | |
| target: | |
| - "$.components.schemas.Transaction.properties" | |
| keys: [ "type" ] | |
| # ── beneficiaryType: beneficiary schemas ── |
Prompt To Fix With AI
This is a comment left during a code review.
Path: .stainless/stainless.yml
Line: 420-446
Comment:
Unresolved merge conflict will break the build
```suggestion
# ── type: transaction base schema ──
- command: remove
reason: >-
Remove inline type enum from Transaction base schema to avoid
conflicting types when allOf merges with IncomingTransaction and
OutgoingTransaction which define type as single-value enums
args:
target:
- "$.components.schemas.Transaction.properties"
keys: [ "type" ]
# ── beneficiaryType: beneficiary schemas ──
```
How can I resolve this? If you propose a fix, please make it concise.eb98c72 to
8ad3ce8
Compare

TL;DR
Fixed transaction schema inheritance by implementing proper polymorphic type handling for transactions.
What changed?
typeproperty from the baseTransactionschema to avoid conflicts when merging with child schemastypeproperty with specific enum values to bothIncomingTransactionandOutgoingTransactionschemasTransactionOneOfschema that uses proper polymorphic discrimination between transaction typesTransactionOneOfinstead of the baseTransactionschemaHow to test?
Why make this change?
The previous schema structure had conflicting type definitions when the base
Transactionschema was merged with specific transaction type schemas throughallOf. This change implements proper polymorphic inheritance using theoneOfdiscriminator pattern, ensuring that transaction types are correctly differentiated and validated. This prevents potential issues with schema validation and improves API documentation clarity.